package leetcode.code5998;

import java.util.ArrayList;
import java.util.List;

import leetcode.IDebug;

//执行用时：12 ms, 在所有 Java 提交中击败了100.00%的用户
//
//内存消耗：58.4 MB, 在所有 Java 提交中击败了100.00%的用户
//
//通过测试用例：56 / 56
public class Solution implements IDebug {

	public List<Long> maximumEvenSplit(long finalSum) {
		List<Long> ans = new ArrayList<>();
		if ((finalSum & 1) == 1) {
			return ans;
		}
		long tmp = finalSum;
		Long cur = 2l;
		while (tmp - cur >= 0) {
			ans.add(cur);
			tmp -= cur;
			cur += 2;
		}
		if (tmp > 0) {
			tmp = tmp + ans.get(ans.size());
			ans.remove(ans.size());
			ans.add(tmp);
		}
		return ans;
	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
